//
//  Home1Card2TableViewCell.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/19.
//  
  

#import "Home1Card2TableViewCell.h"
#import <YYKit.h>
#import <Masonry.h>
//#import "SLWealthChannelComponent.h"
//#import "SLLoanTermsComponent.h"
//#import "SLHelpComponent.h"
//#import "SLCustomerTestimonialsHeadComponent.h"
//#import "SLCustomerTestimonialsItemComponent.h"
//#import "SLCertificationProcessHeadComponent.h"
//#import "SLCertificationProcessItemComponent.h"
#import "DashedLineView.h"

@interface Home1Card2TableViewCell ()
@property (nonatomic, strong) UIView *bgView1;
@property (nonatomic, strong) UIView *bgView2;
@property (nonatomic, strong) UIView *bgView3;
@property (nonatomic, strong) UIView *bgView4;
@end
@implementation Home1Card2TableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.bgView1];
        [self.bgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        SLWealthChannelComponent *wealth = [SLWealthChannelComponent new];
        _wealth = wealth;
        [self.contentView addSubview:wealth];
        [wealth mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.contentView).inset(35);
            make.height.mas_equalTo(54);
            make.top.equalTo(self.bgView1).offset(18);
        }];
        
        [self.contentView addSubview:self.bgView2];
        [self.bgView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.bgView1);
            make.top.equalTo(wealth.mas_bottom).offset(18);
            make.bottom.equalTo(self.bgView1);
        }];
        
        [self.contentView addSubview:self.bgView3];
        [self.bgView3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView2).inset(20);
            make.top.equalTo(self.bgView2).offset(20);
            make.height.mas_equalTo(73);
        }];
        
        SLLoanTermsComponent *terms = [SLLoanTermsComponent new];
        _terms = terms;
        [self.contentView addSubview:terms];
        [terms mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView3).inset(14);
            make.height.mas_equalTo(44);
            make.centerY.equalTo(self.bgView3);
        }];
        
        [self.contentView addSubview:self.bgView4];
        [self.bgView4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView2).inset(20);
            make.top.equalTo(self.bgView3.mas_bottom).offset(20);
            make.bottom.equalTo(self.bgView2).inset(20);
        }];
        
        SLHelpComponent *help = [SLHelpComponent new];
        _help = help;
        [self.contentView addSubview:help];
        [help mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView4).inset(20);
            make.height.mas_equalTo(60);
            make.top.equalTo(self.bgView4).offset(15);
        }];
        
        SLCustomerTestimonialsHeadComponent *customerTestimonialsHead = [SLCustomerTestimonialsHeadComponent new];
        _customerTestimonialsHead = customerTestimonialsHead;
        [self.contentView addSubview:customerTestimonialsHead];
        [customerTestimonialsHead mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView3).inset(20);
            make.height.mas_equalTo(54);
            make.top.equalTo(help.mas_bottom);
        }];
        
        SLCustomerTestimonialsItemComponent *customerTestimonialsItem1 = [SLCustomerTestimonialsItemComponent new];
        [self.contentView addSubview:customerTestimonialsItem1];
        [customerTestimonialsItem1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView4).inset(20);
            make.height.mas_equalTo(100);
            make.top.equalTo(customerTestimonialsHead.mas_bottom);
        }];
        SLCustomerTestimonialsItemComponent *customerTestimonialsItem2 = [SLCustomerTestimonialsItemComponent new];
        [self.contentView addSubview:customerTestimonialsItem2];
        [customerTestimonialsItem2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView4).inset(20);
            make.height.mas_equalTo(100);
            make.top.equalTo(customerTestimonialsItem1.mas_bottom).offset(10);
        }];
        
        DashedLineView *line = [DashedLineView new];
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(customerTestimonialsItem2.mas_bottom).offset(27);
            make.left.right.equalTo(self.bgView4);
            make.height.mas_equalTo(2);
        }];
        
        SLCertificationProcessHeadComponent *head = [SLCertificationProcessHeadComponent new];
        _head = head;
        [self.contentView addSubview:head];
        [head mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView4).inset(20);
            make.top.equalTo(line.mas_bottom).offset(0);
            make.height.mas_equalTo(54);
        }];
        
        SLCertificationProcessItemComponent *item = [SLCertificationProcessItemComponent new];
        [self.contentView addSubview:item];
        item.stepCount = 5;
        item.currentStep = 3;
        [item mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(head.mas_bottom);
            make.left.right.equalTo(self.bgView4).inset(20);
            make.height.mas_equalTo(60);
        }];
        
        UILabel *describe = [UILabel new];
        describe.text = @"Complete The Certification To Apply For A Loan!";
        describe.textAlignment = NSTextAlignmentCenter;
        describe.font = aspectDefaultFont(14);
        describe.textColor = UIColorHex(#666666);
        [self.contentView addSubview:describe];
        [describe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView4).inset(20);
            make.height.mas_equalTo(18);
            make.top.equalTo(item.mas_bottom).offset(10);
            make.bottom.equalTo(self.bgView4).inset(16);
        }];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
}

- (UIView *)bgView1 {
    if (!_bgView1) {
        _bgView1 = [UIView new];
        _bgView1.backgroundColor = UIColorHex(#1B1B1B);
        _bgView1.layer.cornerRadius = 20;
    }
    return _bgView1;
}
- (UIView *)bgView2 {
    if (!_bgView2) {
        _bgView2 = [UIView new];
        _bgView2.backgroundColor = UIColor.whiteColor;
    }
    return _bgView2;
}
- (UIView *)bgView3 {
    if (!_bgView3) {
        _bgView3 = [UIView new];
        _bgView3.backgroundColor = UIColorHex(#F0F0F0);
        _bgView3.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        _bgView3.layer.borderWidth = 1.5;
        _bgView3.layer.cornerRadius = 20;
    }
    return _bgView3;
}
- (UIView *)bgView4 {
    if (!_bgView4) {
        _bgView4 = [UIView new];
        _bgView4.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        _bgView4.layer.borderWidth = 1.5;
        _bgView4.layer.cornerRadius = 20;
    }
    return _bgView4;
}

@end
